<?php
    require('../Utils.php');

    $post = getJsonParamter();

    $username = $post['username'];
    $oldPwd = $post['oldPwd'];
    $newPwd = $post['newPwd'];

    $conn = getConnection();

    $sql = "UPDATE administrator SET password = ? WHERE username = ? AND password = ?";

    $result = execute($conn, $sql, $newPwd, $username, $oldPwd);

    if($result) getJson(200, '修改密码成功', null);

    else getJson(500, '修改密码失败,账号或密码错误', null);
?>